online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
import random def roll_dice(num_dice=1, sides=6): return sum(random.randint(1, sides) for _ in range(num_dice)) def monster_result(): result = roll_dice(2) if result == 2 or result == 12: return 'Dreadnought (25 points)' elif result == 3 or result == 11: return f'Chaos Space Marines: 1 Commander, 1 heavy weapon and {roll_dice()}d3 Marines (5 or 10 points)' elif result == 4 or result == 10: return f'{roll_dice()}d3 Androids (10 points)' elif result == 5 or result == 9: return f'{roll_dice()}d2 Genestealers (5 points)' elif result == 6: return f'{roll_dice()}d3 Orks (3 points) + {roll_dice()}d3 Gretchins (2 points)' elif result == 7: return f'{roll_dice()}d6 Gretchins (2 points)' elif result == 8: return f'{roll_dice() + 1}d3+1 Orks (3 points) + {roll_dice()}d3 Gretchins (2 points)' else: return 'Unknown result' def stranger_result(): result = roll_dice() if result <= 2: return 'Space Marine with heavy weapon' elif result <= 4: return 'Space Marine with Bolter' else: return 'Renegade Ork' def room_result(): result = roll_dice() if result == 1: return 'Empty' elif 2 <= result <= 5: return f'Monster: {monster_result()}' else: # result == 6 special = roll_dice() if special == 1: return 'Alien Event (draw Event card)' elif special == 2: return 'Equipment (choose an Equipment card)' elif special == 3: return 'Order (choose an Order card)' elif special == 4: return f'Roll the dice twice on the Monster table: {monster_result()}, {monster_result()}' elif special == 5: return f'Roll the dice three times on the Monster table: {monster_result()}, {monster_result()}, {monster_result()}' else: # special == 6 return f'Stranger: {stranger_result()}' def corridor_result(): result = roll_dice() if result == 1: special = roll_dice() if special == 1: return 'Alien Event (draw Event card)' elif special == 2: return 'Equipment (choose an Equipment card)' elif special == 3: return 'Order (choose an Order card)' elif special == 4: return f'Monsters: {monster_result()}, {monster_result()}' elif special == 5: return f'Monsters: {monster_result()}, {monster_result()}, {monster_result()}' else: # special == 6 return f'Stranger: {stranger_result()}' elif 2 <= result <= 4: return 'Empty' else: # result >= 5 return f'Monsters: {monster_result()}' print("Press Enter to see the results for one room and one corridor. Type 'q' and press Enter to quit.") while True: user_input = input("Press Enter...") if user_input == 'q': break print("Room result:", room_result()) print("Corridor result:", corridor_result()) print("Thanks for playing!")

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue